home *** CD-ROM | disk | FTP | other *** search
- SH -- by Jim Guilford
-
- This is my version of a utility to unshar files. I wrote it as I found
- existing programs to be unreliable and limited. This works to the best
- of my knowledge, but I make no guarrantees.
-
- The program knows four simple sh commands: echo, cat, sed, and exit.
- The version of sed that I've implemented is SEVERELY limited, but does
- manage to unshar all of the shar files I've seen which use sed. If sh
- finds any other commands, it ignores them.
-
- Sh is invoked as
- sh [options] [filename]
- If the filename is omitted, the standard input is taken. The options
- can be given individually (e.g. -s1 -o1), or combined (e.g. -s1o1).
- The options are as follows:
- -v0 == verbosity of zero. Don't print what isn't understood
- -v1 == verbosity of one. Print what isn't understood
- -v2 == verbosity of two. Print what isn't understood and commands as
- they are executed. This will only echo the cat and sed
- commands. I thought that echoing the 'echo' command was rather
- silly, as is echoing 'exit'.
- -v == without a number is defaults to -v1
- -s0 == safety off. Continue if something is not understood
- -s1 == safety on. Stop the first time something is not understood (in
- case you are paranoid).
- -s == defaults to -s1
- -o0 == overwrite off. Don't check for overwriting existing files.
- -o1 == overwrite on. Don't overwrite files if they already exist
- -o == defaults to -o1
-
- The defaults as compiled into the program are:
- -v1 -s0 -o1
-
- Known bugs:
- In evaluating tokens, I handle quotes properly. The only escape
- character for which I check, however, is the back-slash, '\'. This is
- removed, and the next character is taken as is. If a token contains
- any other escape characters, then it won't be parsed properly. If
- this happens to the token following the '<<', then essentially all of
- the shar file will be dumped into the first file that was to be
- unshared. This is a good indication that funny characters are around.
- If this happens, then the easiest way to fix it is to zip into your
- favorite editor and change one of the pair of terminating string to
- match the other. This can usually be done with one global search and
- replace (once you know the changes to be made).
-
- Programmer's Notes:
- The program is designed to be modular and easily enhanced to
- understand a new shar form. It currently understands the following:
- cat << some-string > file-name
- cat << some-string >> file-name
- sed s/^X// << some-string > file-name
- sed s/^X// << some-string >> file-name
-
- where the sed quote character (e.g. '/') can be anything and the sed
- 'X' character can be anything. Additionally, the ordering of the
- arguments is unimportant as is whether a space follows the indirection
- operators. In other words, this would also be accepted:
- cat >file-name <<"some string"
-
- Just as a side note, it was compiled under lattice 4.0. It should be
- fairly portable, but I make no guarrantees.
-
- If you have any comments, suggestions, or you just want to say hi, I
- can be reached at:
- guilford@turing.cs.rpi.edu
- guilford@csv.rpi.edu
- ...!rutgers!nysernic!rpics!guilford
-
-